package com.gistmap.ntdc.persistence.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author zhangran
 * @date 2018/12/26
 */
@Getter
@Setter
@Entity
@Table(name = "address")
@EntityListeners(AuditingEntityListener.class)
public class Address {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
    /**
     * 地址 e.g. 上海市xxx区xxx路xxx弄
     */
    private String address;
    /**
     * 小区名字 xxx家园
     */
    private String name;
    /**
     * 楼层房号 101号xx室
     */
    private String floor;
    /**
     * address + floor
     */
    private String detail;
    /**
     * 收货人姓名
     */
    private String userName;
    /**
     * 收货人性别
     */
    @Enumerated(EnumType.STRING)
    private Sex sex;
    /**
     * 收货人手机号
     */
    private String mobile;
    /**
     * 默认地址与否
     */
    private boolean checked;

    @LastModifiedDate
    private Date updatedTime;

    @CreatedDate
    private Date createdTime;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "user_id")
    private User user;
}
